# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=bcunit
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.3.101
pkgrel=1
pkgdesc="Lightweight system for writing, administering, and running unit tests in C (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/BelledonneCommunications/bcunit"
license=('spdx:LGPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             'autogen')
source=("https://github.com/BelledonneCommunications/bcunit/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('a89ce3b6034db96e392b6572d4a9d29f7fe7824580b8f28acf2b3da4418f1ac7')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  [ -x configure ] || ./autogen.sh
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
  mv "${pkgdir}${MINGW_PREFIX}"/doc "${pkgdir}${MINGW_PREFIX}"/share/doc
}
